#!/bin/sh
COMM_DIST=../dist
mkdir -p ${COMM_DIST}/bin
FLAG_DEBUG=R
FLAG_EXIT=0
FLAG_MSG=""

. ./cfg_modules

# 获取参数 $1:D表示debug版本
if [ $# -ge 1 ]; then
    FLAG_DEBUG=$1
fi

sh ./mk_base.sh
# 错误检查
if [ 0 != $? ]; then
	echo "complie apm base error!"
	exit 1;
fi

# 模块编译
cd module
for module_name in ${modules_list[@]}  
do  
	cd ${module_name}
	make clean; make
	if [ $? != 0 ]; then
		FLAG_EXIT=1;
		FLAG_MSG=${module_name}
		break;
	fi
	cd ..
done
cd ..

# 错误检查
if [ ${FLAG_EXIT} != 0 ]; then
	echo "complie ${FLAG_MSG} error!"
	exit;
fi

sh ./install.sh $FLAG_DEBUG

